package com.example.test01;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.first_layout);
        Button bt = (Button) findViewById(R.id.Button_01);
        bt.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Toast.makeText(MainActivity.this, "跳转", Toast.LENGTH_SHORT).show();
                //显狮的intent
//                Intent intent = new Intent(MainActivity.this, SecondActivity.class);
                Intent intent = new Intent("com.example.test01.ACTION_START");

                startActivity(intent);
            }
        });
    }

    public boolean onCreateOptionsMenu(Menu menu){
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }

    public boolean onOptionsItemSelected(MenuItem item) {
        switch (item.getItemId()) {
            case R.id.add_item:
                Toast.makeText(MainActivity.this, "添加菜单", Toast.LENGTH_SHORT).show();

                break;
            case R.id.remove_item:
                Toast.makeText(MainActivity.this, "删除菜单", Toast.LENGTH_SHORT).show();
                break;
        }
        return true;
    }
}